const logger = require('koa-logger')
const Koa = require('koa');
const path = require('path')
const bodyParser = require('koa-bodyparser');
const ejs = require('ejs');
//const session = require('koa-session-minimal');
const Router = require('koa-router')
const views = require('koa-views')
const static = require('koa-static')
const staticCache = require('koa-static-cache')
const session = require('koa-session');
const app = new Koa()

app.use(logger())


app.use(static(path.join(__dirname, '/public')));

//模板引擎
app.use(views(path.join(__dirname, '/views'), { extension: 'ejs' }));




let index = require('./routers/index');
//cloud 云盘项目
let cloud = require('./routers/cloud/index'); 
let christmas2017 = require('./routers/christmas2017/index'); 
let commonweal= require('./routers/commonweal/index'); 
//百万答题项目
let quesion=require('./routers/question/index'); 
//支付
let pay=require('./routers/pay/index'); 

app.use(index.routes(),index.allowedMethods());
app.use(cloud.routes(),cloud.allowedMethods());  
app.use( christmas2017.routes(),christmas2017.allowedMethods());  
app.use(commonweal.routes(),commonweal.allowedMethods());  
app.use(quesion.routes(),quesion.allowedMethods());  
app.use(pay.routes(),pay.allowedMethods());  

//post 中间件
app.use(bodyParser())


app.on('error', function(err, ctx){
  console.error('server error', err);
});

app.listen(3000)
